<template>
  <div>这是异步加载组件</div>
  <button @click="unsubHandler">关闭事件监听</button>
</template>
<script>
import emitter from "../util/mitt.js";
import { onMounted } from "vue";
export default {
  setup() {
    const watchHandler = value => {
      console.log("组件件监听触发！" + value);
    };
    onMounted(() => {
      emitter.on("helloPageEmitFun", watchHandler);
    });
    const unsubHandler = () => {
      emitter.off("helloPageEmitFun", watchHandler);
    };
    return {
      unsubHandler,
    };
  },
};
</script>